﻿using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
//using System.Data.Entity.Migrations.History;
//using System.Data.Entity;
using XYAC.Framework.WohuaMesExtend.IHI.Extensions;
using XYAC.Framework.WohuaMesExtend.IHI.IHI.Models;
//using XYAC.Framework.WohuaMesExtend.IHI.Models;

namespace XYAC.Framework.WohuaMesExtend.IHI.DataContext
{
    public class AccessIHIBaseContext : DbContext
    {
        public AccessIHIBaseContext(IOptionsMonitor<AppConfig> moduleConfig) : base()
        {
            this.ConnectionString = moduleConfig.CurrentValue?.AccessIHIBaseConnectionString;
            //Database.SetInitializer<AccessIHIBaseContext>(null);
        }
        public DbSet<SpecInfo_IHI> SpecInfo { get; set; }
        public string ConnectionString { get; }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //modelBuilder.HasDefaultSchema("");
            //modelBuilder.Entity<HistoryRow>().ToTable("EFMigrationHistory").HasKey(h => h.MigrationId);

            base.OnModelCreating(modelBuilder);

        }

        /// <summary>
        /// 当DB发生OnConfiguring用于配置数据库
        /// </summary>
        /// <param name="optionsBuilder"></param>
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            // 配置 SQL Server 数据库连接字符串
            optionsBuilder.UseJet(ConnectionString);
        }
    }

}
